﻿using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using SynoManager.GUI;

namespace SynoManager.DownloadStation.Subscriptions
{
    [ServiceDependency(typeof(DownloadStationService))]
    public class SubscriptionsGuiPlugin : IGuiPlugin
    {
        private IHost host;
        private SynoDevice device;
        private SubscriptionManager manager;

        public SubscriptionsGuiPlugin()
        {
            manager = new SubscriptionManager(this);
        }

        public void InitializeHost(IHost host)
        {
            this.host = host;
        }

        public void Initialize(SynoDevice device)
        {
            service = device.FindService<DownloadStationService>();
            Debug.Assert(service != null, "DownloadStationService could not be found");
            this.device = device;
        }

        public void PopulatePreferencesForm(TreeViewEx treeView)
        {
            
        }

        public void OnConnectionStateChange(bool isConnected, bool wasConnected)
        {
            
        }

        private SubscriptionsGuiTab tab;
        private DownloadStationService service;

        public SubscriptionsGuiTab Tab
        {
            get
            {
                if (tab == null)
                    tab = new SubscriptionsGuiTab(this);

                return tab;
            }
        }

        public System.Windows.Forms.Control MainControl
        {
            get { return Tab; }
        }

        public bool TabActive
        {
            set 
            { 
                // ignore
            }
        }

        public int TabPriority
        {
            get { return 600; }
        }

        public SubscriptionManager Manager
        {
            get { return manager; }
        }

        public DownloadStationService DownloadStation
        {
            get
            {
                return service;
            }
        }
    }
}
